<template>
  <div class="mui-numbox" data-numbox-min="1" style="height:.5rem">
    <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
    <input id="test" class="mui-input-numbox" type="number" :value="numCount" ref="num" @change="numChange" readonly/>
    <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
  </div>
</template>

<script>
import mui from '../../assets/mui/js/mui'
export default {
    data(){
        return{
            
        }
    },
    props:['numCount','shopId'],
    mounted(){
         // 初始化数字选择框组件
        mui(".mui-numbox").numbox();
    },
    methods:{
      numChange(){
      // 数量改变了
      // 每当数量值改变，则立即把最新的数量同步到 购物车的  store 中，覆盖之前的数量值
        // console.log(this.$refs.num.value+this.shopId)
        this.$store.commit('updataShop', {count:this.$refs.num.value,id:this.shopId});
      }
    }
};
</script>

<style lang="scss" scoped>
.mui-numbox{
  touch-action: none;
}
</style>